/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package acceso.dashboard;

import java.awt.Color;
import java.awt.Paint;
import java.lang.reflect.Field;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;
import org.jfree.chart.labels.StandardCategoryToolTipGenerator;
import org.jfree.chart.renderer.category.CategoryItemRenderer;
import org.jfree.chart.renderer.category.StandardBarPainter;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.data.general.Dataset;
import org.jfree.ui.GradientPaintTransformType;
import org.jfree.ui.StandardGradientPaintTransformer;

/**
 *
 * @author romulogalindo
 */
class Custom_Renderer {

    static final Paint[] colors = new Paint[]{
        new Color(Integer.parseInt("3366cc", 16)),
        new Color(Integer.parseInt("dc3912", 16)),
        new Color(Integer.parseInt("ff9900", 16)),
        new Color(Integer.parseInt("109618", 16)),
        new Color(Integer.parseInt("990099", 16)),
        new Color(Integer.parseInt("0099c6", 16)),
        new Color(Integer.parseInt("dd4477", 16)),
        new Color(Integer.parseInt("66aa00", 16)),
        new Color(Integer.parseInt("b82e2e", 16)),
        new Color(Integer.parseInt("316395", 16)),
        new Color(Integer.parseInt("994499", 16)),
        new Color(Integer.parseInt("22aa99", 16)),
        new Color(Integer.parseInt("aaaa11", 16)),
        new Color(Integer.parseInt("6633cc", 16)),
        new Color(Integer.parseInt("e67300", 16)),
        new Color(Integer.parseInt("8b0707", 16)),
        new Color(Integer.parseInt("651067", 16)),
        new Color(Integer.parseInt("329262", 16)),
        new Color(Integer.parseInt("5574a6", 16)),
        new Color(Integer.parseInt("3b3eac", 16)),
        new Color(Integer.parseInt("b77322", 16)),
        new Color(Integer.parseInt("16d620", 16))
    };

    public static CategoryItemRenderer renderer_by_type_chart(Dataset ds, int type, boolean url, boolean border, boolean shadow, boolean extra) {

        CategoryItemRenderer renderer = null;
        switch (type) {
            case 1: {
                //areachart
                renderer = new org.jfree.chart.renderer.category.AreaRenderer();
                java.util.List rows = ((acceso.dashboard.DefaultCategoryDataset) ds).getRowKeys();
                for (int i = 0; i < rows.size(); i++) {
                    String color;
                    Color c;
                    try {
                        color = (String) ((acceso.dashboard.DefaultCategoryDataset) ds).getRowKeys_colors().get(i);
                    } catch (Exception ep) {
                        color = "default";
                    }

                    if (color.contentEquals("default")) {
                        c = (Color) colors[i];
                        ((org.jfree.chart.renderer.category.AreaRenderer) renderer).setSeriesPaint(i, c);
                    } else {
                        try {
                            if (color.startsWith("#")) {
                                c = new Color(Integer.parseInt(color.toLowerCase().replace("#", ""), 16));
                            } else {
                                Field field = Color.class.getField(color.toLowerCase());
                                c = (Color) field.get(null);
                            }
                        } catch (Exception e) {
                            c = (Color) colors[i]; // Not defined
                        }

                        ((org.jfree.chart.renderer.category.AreaRenderer) renderer).setSeriesPaint(i, c);
                    }
                }

                if (url) {
                    ((org.jfree.chart.renderer.category.AreaRenderer) renderer).setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
                }
                break;
            }
            case 2: {
                renderer = new org.jfree.chart.renderer.category.StackedAreaRenderer();
                java.util.List rows = ((acceso.dashboard.DefaultCategoryDataset) ds).getRowKeys();
                for (int i = 0; i < rows.size(); i++) {
                    String color = "";
                    Color c = null;
                    try {
                        color = (String) ((acceso.dashboard.DefaultCategoryDataset) ds).getRowKeys_colors().get(i);
                    } catch (Exception ep) {
                        color = "default";
                    }

                    if (color.contentEquals("default")) {
                        c = (Color) colors[i];
                        ((org.jfree.chart.renderer.category.StackedAreaRenderer) renderer).setSeriesPaint(i, c);
                    } else {
                        try {
                            if (color.startsWith("#")) {
                                c = new Color(Integer.parseInt(color.toLowerCase().replace("#", ""), 16));
                            } else {
                                Field field = Color.class.getField(color.toLowerCase());
                                c = (Color) field.get(null);
                            }
                        } catch (Exception e) {
                            c = (Color) colors[i]; // Not defined
                        }

                        ((org.jfree.chart.renderer.category.StackedAreaRenderer) renderer).setSeriesPaint(i, c);
                    }
                }

                if (url) {
                    ((org.jfree.chart.renderer.category.StackedAreaRenderer) renderer).setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
                }
                break;
            }
            case 3: {
                renderer = new org.jfree.chart.renderer.category.BarRenderer();

                java.util.List rows = ((acceso.dashboard.DefaultCategoryDataset) ds).getRowKeys();
                for (int i = 0; i < rows.size(); i++) {
                    String color = "";
                    Color c = null;
                    try {
                        color = (String) ((acceso.dashboard.DefaultCategoryDataset) ds).getRowKeys_colors().get(i);
                    } catch (Exception ep) {
                        color = "default";
                    }

                    if (color.contentEquals("default")) {
                        c = (Color) colors[i];
                        ((org.jfree.chart.renderer.category.BarRenderer) renderer).setSeriesPaint(i, c);
                    } else {
                        try {
                            if (color.startsWith("#")) {
                                c = new Color(Integer.parseInt(color.toLowerCase().replace("#", ""), 16));
                            } else {
                                Field field = Color.class.getField(color.toLowerCase());
                                c = (Color) field.get(null);
                            }
                        } catch (Exception e) {
                            c = (Color) colors[i]; // Not defined
                        }

                        ((org.jfree.chart.renderer.category.BarRenderer) renderer).setSeriesPaint(i, c);
                    }
                }
                ((org.jfree.chart.renderer.category.BarRenderer) renderer).setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL));
                ((org.jfree.chart.renderer.category.BarRenderer) renderer).setBarPainter(new StandardBarPainter());
                ((org.jfree.chart.renderer.category.BarRenderer) renderer).setDrawBarOutline(border);
                ((org.jfree.chart.renderer.category.BarRenderer) renderer).setShadowVisible(shadow);
                if (url) {
                    ((org.jfree.chart.renderer.category.BarRenderer) renderer).setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
                }

                break;
            }
            case 4: {
                renderer = new org.jfree.chart.renderer.category.BarRenderer3D();

                java.util.List rows = ((acceso.dashboard.DefaultCategoryDataset) ds).getRowKeys();
                for (int i = 0; i < rows.size(); i++) {
                    String color = "";
                    Color c = null;
                    try {
                        color = (String) ((acceso.dashboard.DefaultCategoryDataset) ds).getRowKeys_colors().get(i);
                    } catch (Exception ep) {
                        color = "default";
                    }

                    if (color.contentEquals("default")) {
                        c = (Color) colors[i];
                        ((org.jfree.chart.renderer.category.BarRenderer3D) renderer).setSeriesPaint(i, c);
                    } else {
                        try {
                            if (color.startsWith("#")) {
                                c = new Color(Integer.parseInt(color.toLowerCase().replace("#", ""), 16));
                            } else {
                                Field field = Color.class.getField(color.toLowerCase());
                                c = (Color) field.get(null);
                            }
                        } catch (Exception e) {
                            c = (Color) colors[i]; // Not defined
                        }

                        ((org.jfree.chart.renderer.category.BarRenderer3D) renderer).setSeriesPaint(i, c);
                    }
                }

                ((org.jfree.chart.renderer.category.BarRenderer3D) renderer).setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL));
                ((org.jfree.chart.renderer.category.BarRenderer3D) renderer).setBarPainter(new StandardBarPainter());
                ((org.jfree.chart.renderer.category.BarRenderer3D) renderer).setDrawBarOutline(border);
                ((org.jfree.chart.renderer.category.BarRenderer3D) renderer).setShadowVisible(shadow);
                if (url) {
                    ((org.jfree.chart.renderer.category.BarRenderer3D) renderer).setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
                }
                break;
            }
            case 5: {//layeredbarchart
                renderer = new org.jfree.chart.renderer.category.LayeredBarRenderer();

                java.util.List rows = ((acceso.dashboard.DefaultCategoryDataset) ds).getRowKeys();
                for (int i = 0; i < rows.size(); i++) {
                    String color = "";
                    Color c = null;
                    try {
                        color = (String) ((acceso.dashboard.DefaultCategoryDataset) ds).getRowKeys_colors().get(i);
                    } catch (Exception ep) {
                        color = "default";
                    }

                    if (color.contentEquals("default")) {
                        c = (Color) colors[i];
                        ((org.jfree.chart.renderer.category.LayeredBarRenderer) renderer).setSeriesPaint(i, c);
                    } else {
                        try {
                            if (color.startsWith("#")) {
                                c = new Color(Integer.parseInt(color.toLowerCase().replace("#", ""), 16));
                            } else {
                                Field field = Color.class.getField(color.toLowerCase());
                                c = (Color) field.get(null);
                            }
                        } catch (Exception e) {
                            c = (Color) colors[i]; // Not defined
                        }

                        ((org.jfree.chart.renderer.category.LayeredBarRenderer) renderer).setSeriesPaint(i, c);
                    }
                }


                ((org.jfree.chart.renderer.category.LayeredBarRenderer) renderer).setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL));
                ((org.jfree.chart.renderer.category.LayeredBarRenderer) renderer).setBarPainter(new StandardBarPainter());
                ((org.jfree.chart.renderer.category.LayeredBarRenderer) renderer).setDrawBarOutline(border);
                ((org.jfree.chart.renderer.category.LayeredBarRenderer) renderer).setShadowVisible(shadow);
                if (url) {
                    ((org.jfree.chart.renderer.category.LayeredBarRenderer) renderer).setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
                }
                break;
            }
            case 6: {
                renderer = new org.jfree.chart.renderer.category.GroupedStackedBarRenderer();

                java.util.List rows = ((acceso.dashboard.DefaultCategoryDataset) ds).getRowKeys();
                for (int i = 0; i < rows.size(); i++) {
                    String color = "";
                    Color c = null;
                    try {
                        color = (String) ((acceso.dashboard.DefaultCategoryDataset) ds).getRowKeys_colors().get(i);
                    } catch (Exception ep) {
                        color = "default";
                    }

                    if (color.contentEquals("default")) {
                        c = (Color) colors[i];
                        ((org.jfree.chart.renderer.category.StackedBarRenderer) renderer).setSeriesPaint(i, c);
                    } else {
                        try {
                            if (color.startsWith("#")) {
                                c = new Color(Integer.parseInt(color.toLowerCase().replace("#", ""), 16));
                            } else {
                                Field field = Color.class.getField(color.toLowerCase());
                                c = (Color) field.get(null);
                            }
                        } catch (Exception e) {
                            c = (Color) colors[i]; // Not defined
                        }

                        ((org.jfree.chart.renderer.category.StackedBarRenderer) renderer).setSeriesPaint(i, c);
                    }
                }


                ((org.jfree.chart.renderer.category.StackedBarRenderer) renderer).setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL));
                ((org.jfree.chart.renderer.category.StackedBarRenderer) renderer).setBarPainter(new StandardBarPainter());
                ((org.jfree.chart.renderer.category.StackedBarRenderer) renderer).setDrawBarOutline(border);
                ((org.jfree.chart.renderer.category.StackedBarRenderer) renderer).setShadowVisible(shadow);
                if (url) {
                    ((org.jfree.chart.renderer.category.StackedBarRenderer) renderer).setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
                }
                break;
            }
            case 7: {
                renderer = new org.jfree.chart.renderer.category.StackedBarRenderer3D();


                java.util.List rows = ((acceso.dashboard.DefaultCategoryDataset) ds).getRowKeys();
                for (int i = 0; i < rows.size(); i++) {
                    String color = "";
                    Color c = null;
                    try {
                        color = (String) ((acceso.dashboard.DefaultCategoryDataset) ds).getRowKeys_colors().get(i);
                    } catch (Exception ep) {
                        color = "default";
                    }

                    if (color.contentEquals("default")) {
                        c = (Color) colors[i];
                        ((org.jfree.chart.renderer.category.StackedBarRenderer3D) renderer).setSeriesPaint(i, c);
                    } else {
                        try {
                            if (color.startsWith("#")) {
                                c = new Color(Integer.parseInt(color.toLowerCase().replace("#", ""), 16));
                            } else {
                                Field field = Color.class.getField(color.toLowerCase());
                                c = (Color) field.get(null);
                            }
                        } catch (Exception e) {
                            c = (Color) colors[i]; // Not defined
                        }

                        ((org.jfree.chart.renderer.category.StackedBarRenderer3D) renderer).setSeriesPaint(i, c);
                    }
                }


                ((org.jfree.chart.renderer.category.StackedBarRenderer3D) renderer).setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL));
                ((org.jfree.chart.renderer.category.StackedBarRenderer3D) renderer).setBarPainter(new StandardBarPainter());
                ((org.jfree.chart.renderer.category.StackedBarRenderer3D) renderer).setDrawBarOutline(border);
                ((org.jfree.chart.renderer.category.StackedBarRenderer3D) renderer).setShadowVisible(shadow);
                if (url) {
                    ((org.jfree.chart.renderer.category.StackedBarRenderer3D) renderer).setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
                }
                break;
            }
            case 8: {
                renderer = new org.jfree.chart.renderer.category.LineAndShapeRenderer();
                java.util.List rows = ((acceso.dashboard.DefaultCategoryDataset) ds).getRowKeys();
                for (int i = 0; i < rows.size(); i++) {
                    String color = "";
                    Color c = null;
                    try {
                        color = (String) ((acceso.dashboard.DefaultCategoryDataset) ds).getRowKeys_colors().get(i);
                    } catch (Exception ep) {
                        color = "default";
                    }

                    if (color.contentEquals("default")) {
                        c = (Color) colors[ extra ? (colors.length - (i + 1)) : i];
                        ((org.jfree.chart.renderer.category.LineAndShapeRenderer) renderer).setSeriesPaint(i, c);
                    } else {
                        try {
                            if (color.startsWith("#")) {
                                c = new Color(Integer.parseInt(color.toLowerCase().replace("#", ""), 16));
                            } else {
                                Field field = Color.class.getField(color.toLowerCase());
                                c = (Color) field.get(null);
                            }
                        } catch (Exception e) {
                            c = (Color) colors[extra ? (colors.length - (i + 1)) : i]; // Not defined
                        }

                        ((org.jfree.chart.renderer.category.LineAndShapeRenderer) renderer).setSeriesPaint(i, c);
                    }
                }

                if (url) {
                    ((org.jfree.chart.renderer.category.LineAndShapeRenderer) renderer).setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
                }
                break;
            }
            case 15: {
                renderer = new org.jfree.chart.renderer.category.LineAndShapeRenderer(true, false);
//                renderer = new org.jfree.chart.renderer.category.XYLineAndShapeRenderer(true, false);
                java.util.List rows = ((acceso.dashboard.DefaultCategoryDataset) ds).getRowKeys();
                for (int i = 0; i < rows.size(); i++) {
                    String color = "";
                    Color c = null;
                    try {
                        color = (String) ((acceso.dashboard.DefaultCategoryDataset) ds).getRowKeys_colors().get(i);
                    } catch (Exception ep) {
                        color = "default";
                    }

                    if (color.contentEquals("default")) {
                        c = (Color) colors[ extra ? (colors.length - (i + 1)) : i];
                        ((org.jfree.chart.renderer.category.LineAndShapeRenderer) renderer).setSeriesPaint(i, c);
                    } else {
                        try {
                            if (color.startsWith("#")) {
                                c = new Color(Integer.parseInt(color.toLowerCase().replace("#", ""), 16));
                            } else {
                                Field field = Color.class.getField(color.toLowerCase());
                                c = (Color) field.get(null);
                            }
                        } catch (Exception e) {
                            c = (Color) colors[extra ? (colors.length - (i + 1)) : i]; // Not defined
                        }
//                        new XYLineAndShapeRenderer(true, false);
                        ((org.jfree.chart.renderer.category.LineAndShapeRenderer) renderer).setSeriesPaint(i, c);

                    }
                }

//                if (url) {
//                    ((org.jfree.chart.renderer.category.LineAndShapeRenderer) renderer).setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
//                }
                break;
            }
            case 9: {
                renderer = new org.jfree.chart.renderer.category.LineRenderer3D();

                java.util.List rows = ((acceso.dashboard.DefaultCategoryDataset) ds).getRowKeys();
                for (int i = 0; i < rows.size(); i++) {
                    String color = "";
                    Color c = null;
                    try {
                        color = (String) ((acceso.dashboard.DefaultCategoryDataset) ds).getRowKeys_colors().get(i);
                    } catch (Exception ep) {
                        color = "default";
                    }

                    if (color.contentEquals("default")) {
                        c = (Color) colors[i];
                        ((org.jfree.chart.renderer.category.LineRenderer3D) renderer).setSeriesPaint(i, c);
                    } else {
                        try {
                            if (color.startsWith("#")) {
                                c = new Color(Integer.parseInt(color.toLowerCase().replace("#", ""), 16));
                            } else {
                                Field field = Color.class.getField(color.toLowerCase());
                                c = (Color) field.get(null);
                            }
                        } catch (Exception e) {
                            c = (Color) colors[i]; // Not defined
                        }

                        ((org.jfree.chart.renderer.category.LineRenderer3D) renderer).setSeriesPaint(i, c);
                    }
                }
                if (url) {
                    ((org.jfree.chart.renderer.category.LineRenderer3D) renderer).setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
                }
                break;
            }
            case 12: {
                renderer = new org.jfree.chart.renderer.category.LineRenderer3D();

                java.util.List rows = ((acceso.dashboard.DefaultCategoryDataset) ds).getRowKeys();
                for (int i = 0; i < rows.size(); i++) {
                    String color = "";
                    Color c = null;
                    try {
                        color = (String) ((acceso.dashboard.DefaultCategoryDataset) ds).getRowKeys_colors().get(i);
                    } catch (Exception ep) {
                        color = "default";
                    }

                    if (color.contentEquals("default")) {
                        c = (Color) colors[i];
                        ((org.jfree.chart.renderer.category.LineRenderer3D) renderer).setSeriesPaint(i, c);
                    } else {
                        try {
                            if (color.startsWith("#")) {
                                c = new Color(Integer.parseInt(color.toLowerCase().replace("#", ""), 16));
                            } else {
                                Field field = Color.class.getField(color.toLowerCase());
                                c = (Color) field.get(null);
                            }
                        } catch (Exception e) {
                            c = (Color) colors[i]; // Not defined
                        }

                        ((org.jfree.chart.renderer.category.LineRenderer3D) renderer).setSeriesPaint(i, c);
                    }
                }
                if (url) {
                    ((org.jfree.chart.renderer.category.LineRenderer3D) renderer).setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
                }
                break;
            }
            case 13: {
                renderer = new org.jfree.chart.renderer.category.LineRenderer3D();

                java.util.List rows = ((acceso.dashboard.DefaultCategoryDataset) ds).getRowKeys();
                for (int i = 0; i < rows.size(); i++) {
                    String color = "";
                    Color c = null;
                    try {
                        color = (String) ((acceso.dashboard.DefaultCategoryDataset) ds).getRowKeys_colors().get(i);
                    } catch (Exception ep) {
                        color = "default";
                    }

                    if (color.contentEquals("default")) {
                        c = (Color) colors[i];
                        ((org.jfree.chart.renderer.category.LineRenderer3D) renderer).setSeriesPaint(i, c);
                    } else {
                        try {
                            if (color.startsWith("#")) {
                                c = new Color(Integer.parseInt(color.toLowerCase().replace("#", ""), 16));
                            } else {
                                Field field = Color.class.getField(color.toLowerCase());
                                c = (Color) field.get(null);
                            }
                        } catch (Exception e) {
                            c = (Color) colors[i]; // Not defined
                        }

                        ((org.jfree.chart.renderer.category.LineRenderer3D) renderer).setSeriesPaint(i, c);
                    }
                }
                if (url) {
                    ((org.jfree.chart.renderer.category.LineRenderer3D) renderer).setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
                }
                break;
            }
            case 18: {
                renderer = new ExtendedStackedBarRenderer(true);

                java.util.List rows = ((acceso.dashboard.DefaultCategoryDataset) ds).getRowKeys();
                for (int i = 0; i < rows.size(); i++) {
                    String color = "";
                    Color c = null;
                    try {
                        color = (String) ((acceso.dashboard.DefaultCategoryDataset) ds).getRowKeys_colors().get(i);
                    } catch (Exception ep) {
                        color = "default";
                    }

                    if (color.contentEquals("default")) {
                        c = (Color) colors[i];
                        renderer.setSeriesPaint(i, c);
                    } else {
                        try {
                            if (color.startsWith("#")) {
                                c = new Color(Integer.parseInt(color.toLowerCase().replace("#", ""), 16));
                            } else {
                                Field field = Color.class.getField(color.toLowerCase());
                                c = (Color) field.get(null);
                            }
                        } catch (Exception e) {
                            c = (Color) colors[i]; // Not defined
                        }

                        ((ExtendedStackedBarRenderer) renderer).setSeriesPaint(i, c);
                    }
                }


                ((ExtendedStackedBarRenderer) renderer).setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL));
                ((ExtendedStackedBarRenderer) renderer).setBarPainter(new StandardBarPainter());
                ((ExtendedStackedBarRenderer) renderer).setDrawBarOutline(border);
                ((ExtendedStackedBarRenderer) renderer).setShadowVisible(shadow);
                ((ExtendedStackedBarRenderer) renderer).setNumberformat(new DecimalFormat("## %"));
                ((ExtendedStackedBarRenderer) renderer).setShowfirstpercent(true);


                ((ExtendedStackedBarRenderer) renderer).setBaseItemLabelsVisible(true);
//                if (url) {
//                    ((org.jfree.chart.renderer.category.StackedBarRenderer) renderer).setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
//                }
                ((ExtendedStackedBarRenderer) renderer).setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}", NumberFormat.getIntegerInstance(), new DecimalFormat("0.0%")));
                break;
            }
            case 19: {
                renderer = new org.jfree.chart.renderer.category.StackedBarRenderer3D(true);

                java.util.List rows = ((acceso.dashboard.DefaultCategoryDataset) ds).getRowKeys();
                for (int i = 0; i < rows.size(); i++) {
                    String color = "";
                    Color c = null;
                    try {
                        color = (String) ((acceso.dashboard.DefaultCategoryDataset) ds).getRowKeys_colors().get(i);
                    } catch (Exception ep) {
                        color = "default";
                    }

                    if (color.contentEquals("default")) {
                        c = (Color) colors[i];
                        renderer.setSeriesPaint(i, c);
                    } else {
                        try {
                            if (color.startsWith("#")) {
                                c = new Color(Integer.parseInt(color.toLowerCase().replace("#", ""), 16));
                            } else {
                                Field field = Color.class.getField(color.toLowerCase());
                                c = (Color) field.get(null);
                            }
                        } catch (Exception e) {
                            c = (Color) colors[i]; // Not defined
                        }
                        ((org.jfree.chart.renderer.category.StackedBarRenderer3D) renderer).setSeriesPaint(i, c);
                    }
                }

                ((org.jfree.chart.renderer.category.StackedBarRenderer3D) renderer).setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL));
                ((org.jfree.chart.renderer.category.StackedBarRenderer3D) renderer).setBarPainter(new StandardBarPainter());
                ((org.jfree.chart.renderer.category.StackedBarRenderer3D) renderer).setDrawBarOutline(border);
                ((org.jfree.chart.renderer.category.StackedBarRenderer3D) renderer).setDrawBarOutline(border);
                ((org.jfree.chart.renderer.category.StackedBarRenderer3D) renderer).setShadowVisible(shadow);

                ((org.jfree.chart.renderer.category.StackedBarRenderer3D) renderer).setBaseItemLabelsVisible(true);
                ((org.jfree.chart.renderer.category.StackedBarRenderer3D) renderer).setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}", NumberFormat.getIntegerInstance(), new DecimalFormat("0.0%")));
                break;
            }
        }

        return renderer;
    }
}